﻿using System;
using System.Collections.Generic;
using System.Linq;
using Web.Models;
using Model.Core.DataBase;
using Web.Models.AnalysisData;


namespace Web.BML.AnalysisData
{
    /// <summary>
    /// 报文分析
    /// </summary>
    public class ReportAnalysisOp
    {

        private static ReportAnalysisOp instance;
        
        /// <summary>
        /// 单例模式实例化
        /// </summary>
        /// <returns></returns>
        public static ReportAnalysisOp GetInstance()
        {
            if (instance == null)
            {
                instance = new ReportAnalysisOp();
            }
            return instance;
        }


        /// <summary>
        ///     查询用户的报文统计分析
        /// </summary>
        /// <param name="mmsi">MMSI</param>
        /// <returns></returns>
        public List<ReportAnalysis> QueryUserReportAnalyses(String mmsi)
        {
            using (IDbContext db = ContainerFactory.OpenAnalysisConnect())
            {
                return db.Queryable<ReportAnalysis>().Where(m => mmsi.Contains(m.MMSI)).ToList();
            }
        }
    }


}

